package com.service.impl;

import com.dao.FromIdDao;
import com.entity.FormIdInfo;
import com.service.FromIdService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2019/2/18 0018.
 */
@Service
public class FromIdServiceImpl implements FromIdService{
    @Autowired
    private FromIdDao dao;

    @Override
    public String findOpenId(String userId) {
        return dao.findOpenId(userId);
    }

    @Override
    public int insertFormId(String userId, String formId) {
        Date startTime = new Date();
        long asd = startTime.getTime();
        long sdd = asd + 24 * 60 * 60 * 1000 * 7;
        Date endTime = new Date(Long.valueOf(sdd) + 000);
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dao.insertFormId(userId, formId, f.format(startTime), f.format(endTime));
    }

    @Override
    public List<FormIdInfo> selectOhterFormId(String userId) {
        return dao.selectOhterFormId(userId);
    }

    @Override
    public int updateFormId(Integer id) {
        int success = dao.updateFormId(id);
        return success;
    }
}
